package img 
{
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.events.Event;
	import ru.gosoplata.model.TmpModel;
	
	/**
	 * TODO: переписать вью на перья
	 */
	public class ScalePlaneNoText extends Sprite 
	{
		private var pwd:Number;
		private var pl_left:Bitmap =new Bitmap();
		private var pl_right:Bitmap=new Bitmap();
		private var pl_center:Bitmap=new Bitmap();
		
		public function ScalePlaneNoText(plane_width:Number) 
		{
			pwd = plane_width;
			addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		public function init(e:Event=null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			createPlane();
		}
		
		private function createPlane():void 
		{
			pl_left.bitmapData = TmpModel.loadedImages.getBitmapDataByName("plane_uni_left").bitmapData;
			pl_right.bitmapData = TmpModel.loadedImages.getBitmapDataByName("plane_uni_right").bitmapData;
			pl_center.bitmapData = TmpModel.loadedImages.getBitmapDataByName("plane_uni_center").bitmapData;
			
			pl_center.width = pwd - pl_left.width - pl_right.width;
			
			pl_left.x = 0;
			addChild(pl_left);
			pl_center.x = pl_left.x + pl_left.width;
			addChild(pl_center);
			pl_right.x = pl_center.x + pl_center.width;
			addChild(pl_right);
		}
		
		public function reScale(plane_wd:Number):void 
		{
			pwd = plane_wd;

			pl_center.width = pwd - pl_left.width - pl_right.width;
			
			pl_left.x = 0;
			pl_center.x = pl_left.x + pl_left.width;
			pl_right.x = pl_center.x + pl_center.width;
		}
	}
}